package org.me.nyx.adapters;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.me.nyx.R;
import org.me.nyx.data.DataAdapter;
import org.me.nyx.domain.Movie;

public class MovieAdapter extends DataAdapter<Movie> {
    public MovieAdapter(Activity activity, int textViewResourceId) {
	super(activity, textViewResourceId);
    }

    static class MovieRowHolder {
		TextView text;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
		MovieRowHolder holder;
		if (view == null) {
			view = layoutInflater.inflate(R.layout.movie_row, null);

			holder = new MovieRowHolder();
			holder.text = (TextView) view.findViewById(R.id.movie_text);
			view.setTag(holder);
		} else
			holder = (MovieRowHolder) view.getTag();

		Movie o = (Movie) list.get(position);
		if (o != null)
			holder.text.setText(o.getName());
		return view;
    }
}